<template>
  <div class="block">
    <el-timeline>
      <el-timeline-item
        v-for="(item, index) of timeline"
        :key="index"
        :timestamp="item.accessTime"
        placement="top"
      >
        <el-card>
          <h4>{{ item.msg }}</h4>
          <p>登录IP: {{ item.ipaddr }}</p>
        </el-card>
      </el-timeline-item>
    </el-timeline>
  </div>
</template>
<script>
import api from '@/api/system/logs'
import { mapGetters } from 'vuex'
export default {
  data() {
    return {
      timeline: {
        accessTime: '',
        msg: '',
        ipaddr: ''
      }
    }
  },
  computed: {
    ...mapGetters([
      'name'
    ])
  },
  created() {
    this.getLoginlogData()
  },
  methods: {
    getLoginlogData() {
      api.getLooginLogByUserName(this.name).then(res => {
        this.timeline = res.data
      })
    }
  }
}
</script>
